package DAO;
import hibernateUtil.HibernateUtil;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class GetMenuInfoDAO {
	public List getTree()
	{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			Transaction trans = session.beginTransaction();
			List l = session.createQuery("from Tree_menu").list();
			trans.commit();
			return l;
	}
	public List getRoot(String tree_menu_id)
	{
			Session session = HibernateUtil.getSessionFactory().getCurrentSession();
			Transaction trans = session.beginTransaction();
			List l = session.createQuery("from Root_menu where tree_menu_id =:tree_menu_id").setParameter("tree_menu_id", tree_menu_id).list();
			trans.commit();
			return l;
	}
	
	public List validateUser(String userName,String password){
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		Transaction trans = session.beginTransaction();
		List l = session.createQuery("from User where userName =:userName and password =:password").setParameter("userName", userName).setParameter("password", password).list();
		trans.commit();
		return l;		
	}
}
